
<template>
   <section class="oa-form__table">
    <h5>{{approve.name}}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>
          {{ approve.name }}
          <span v-if="approve && approve.code">{{ approve.code }}</span>
        </td>
      </tr>
      <tr>
        <td>流程名称</td>
        <td>
          <span v-if="$route.query.from == 'new'">
            新建{{approve.name}}
          </span>
          <span v-else>
            {{approve.approve_name}}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <!-- <span v-if="$route.query.from === 'new'">{{ approve.name }}</span>
      <span v-else>
        {{ approve.approve_name }}
      </span> -->
    </h3>
    <table class="achievement__tab">
      <tr class="border_0">
        <td width="80">考核周期:</td>
        <td width="110">
          <el-date-picker
            value-format="yyyy-MM-dd"
            type="date"
            v-model="applyTime"
            :disabled="$route.query.from !== 'new'"
            placeholder="考核周期">
          </el-date-picker>
        </td>
        <td>部门:</td>
        <td>
          <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
            <el-option
              v-for="item in departments"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </td>
        <td>姓名:</td>
        <td>
          <el-select v-model="value" style="width:60%" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
            <el-option
              v-for="item in staff"
              :key="item.value"
              :label="item.label"
              :value="item">
            </el-option>
          </el-select>
        </td>
        <!-- <td>岗位:</td> -->
        <td>职位:</td>
        <td><el-input v-model="gangwei" :disabled="$route.query.from !== 'new'" placeholder="职位"/></td>
        <td></td>
      </tr>
    <tr>
      <td class="_name" colspan="2">KPI</td>
      <td class="_name">指标定义</td>
      <td class="_name">权重</td>
      <td class="_name">数据提供</td>
      <td class="_name">计划完成量</td>
      <td class="_name">实际完成量</td>
      <td class="_name">超额完成量</td>
      <td class="_name">评估得分</td>
      <!-- <td class="_name">扣分事项说明</td> -->
    </tr>
    <tr>
      <td rowspan="5">考核指标</td>
      <td>总业绩(万元)</td>
      <td>当月总销售业绩金额</td>
      <td>70%</td>
      <td>财务部</td>
      <td><el-input v-model="obj.a12" :disabled="obj.a12Flag" placeholder="总业绩计划完成量"/></td>
      <td><el-input v-model="obj.a14" :disabled="obj.a14Flag" placeholder="总业绩实际完成量"/></td>
      <td><el-input v-model="b1" :disabled="obj.b1Flag" placeholder="总业绩超额完成量"/></td>
      <td><el-input v-model="obj.a18" :disabled="obj.a18Flag" placeholder="总业绩评估得分"/></td>
    </tr>
    <tr>
      <td>成交客户</td>
      <td>每月成交4个客户</td>
      <td>10%</td>
      <td>财务部</td>
      <td><el-input v-model="obj.a13" :disabled="obj.a13Flag" placeholder="新客户计划完成量"/></td>
      <td><el-input v-model="obj.a15" :disabled="obj.a15Flag" placeholder="新客户实际完成量"/></td>
      <td><el-input v-model="b2" :disabled="obj.b2Flag" placeholder="新客户超额完成量"/></td>
      <td><el-input v-model="obj.a19" :disabled="obj.a19Flag" placeholder="新客户评估得分"/></td>
    </tr>
    <tr>
      <td>销售管理</td>
      <td>部门各项业绩目标完成情况</td>
      <td>15%</td>
      <td>财务部</td>
      <td><el-input v-model="obj.a16" :disabled="obj.a16Flag" placeholder="销售管理计划完成量"/></td>
      <td><el-input v-model="obj.a17" :disabled="obj.a17Flag" placeholder="销售管理实际完成量"/></td>
      <td><el-input v-model="b3" :disabled="obj.b3Flag" placeholder="展业超额完成量"/></td>
      <td><el-input v-model="obj.a606" :disabled="obj.a606Flag" placeholder="销售管理评估得分"/></td>
    </tr>
    <tr>
      <td>遵守公司规章制度</td>
      <td>
        对公司制度及企业文化的理解和执行，
        履行本部门工作中的行为表现
      </td>
      <td>5%</td>
      <td>直属上级</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><el-input v-model="obj.a607" :disabled="obj.a607Flag" placeholder="遵守公司规章制度评估得分"/></td>
      <!-- <td>&nbsp;</td> -->
    </tr>
    <tr>
      <td colspan="2"> </td>
      <td colspan="3"> </td>
      <td colspan="3">综合考核率:{{myScore}}</td>
      </tr>
      <tr>
        <td colspan="9">
          本人已认真阅读并认可本绩效考核评定表，同意遵循并执行本绩效考核评定表。
          <p>
            1、月度业绩目标根据部门总经理提交的基数，计算方式：每月实际的销售业绩÷目标值=X,根据X符合的相对应条件：
          ①50%≤X&lt;60%，得50%；②60%≤X&lt;75%,得65%；③75%≤X&lt;90%,得75%；④X>90%，得100%(X&lt;50%,按实际业绩完成率得分）
          绩效考核分=得分×权重（70%）。<br/>

          2、新客户开发根据在财务部刘小娇报备数量，计算方式：实际成交客户÷目标值×权重（10%）<br/>

          3、部门各项业绩目标完成情况：：
          ①50%≤X&lt;60%，得50%；②60%≤X&lt;75%,得65%；③75%≤X&lt;90%,得75%；④X>90%，得100%(X&lt;50%,按实际业绩完成率得分）
          展业得分=得分×权重（15%）。
          </p>
        </td>
      </tr>
  </table>
    <history :process="process"></history>
    <files></files>
  </section>
</template>
<script>
import mixin from '@/mixins/index.js'
import history from '../service/components/process'
import files from '../service/components/files'
import { sum } from '@/utils/domUtils.js'
const obj = {}
for (let i = 12; i <= 19; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
for (let i = 606; i <= 607; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
for (let i = 627; i <= 629; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
for (let i = 1; i <= 4; i++) {
  obj[`b${i}`] = ''
  obj[`b${i}Flag`] = true
}
console.log(Object.keys(obj))
export default {
  mixins: [mixin],
  data () {
    return {
      reason: '',
      truename: '',
      department: '',
      flag: false,
      value: '',
      obj: JSON.parse(JSON.stringify(obj)),
      applyTime: '',
      gangwei: '',
      file_paths: [],
      file_names: [],
      field_ids: [],
      field_vals: [],
      autoField: []
    }
  },
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'addDofield', 'departments', 'process'],
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    },
    myScore () {
      const result = [this.obj.a18, this.obj.a19, this.obj.a606, this.obj.a607]
      return sum(result)
    },
    b1 () {
      return this.obj.a14 - this.obj.a12
    },
    b2 () {
      return this.obj.a15 - this.obj.a13
    },
    b3 () {
      return this.obj.a17 - this.obj.a16
    }
  },
  watch: {
    addDofield () {
      this.addDofieldRender()
    }
  },
  mounted () {
    this.$nextTick(() => {
      // this.obj = JSON.parse(JSON.stringify(obj))
      if (this.$route.query.from === 'new') {
        this.disabled = true
      } else {
        this.infoFunc()
      }
    })
  },
  methods: {
  }
}
</script>
